package router

import (

	"github.com/gin-gonic/gin"
	"root/controller"
	"root/middleware"
)


func Load(g *gin.Engine) *gin.Engine {
	g.Use(gin.Recovery())
	// 404
	g.NoRoute(func (c *gin.Context)  {
		controller.SendResponse(c,404,"",nil)
		return
	})

	 v1 :=g.Group("/v1")
	{
		v1.POST("/sendCode", controller.SendCode)
		//注册
		v1.POST("/register", controller.Register)
		//登录
		v1.POST("/login", controller.Login)
		v1.Use(middleware.JWTAuth())
		v1.Use(middleware.Sign())
		//获取基本配置
		v1.POST("/getBaseConfig", controller.GetBaseConfig)
		//获取基本配置
		v1.POST("/getShareUrl", controller.GetShareUrl)
		//获取七牛上传token
		v1.POST("/getUploadToken", controller.GetUploadToken)
		//获取分享列表
		v1.POST("/getShareList", controller.GetShareList)
	}
	// Simple group: v2
	v2 := g.Group("/admin")
	{
		v2.GET("/test", controller.Register)
	}

	return g
}
